package com.hua.method;
//斐波那契数列 ,「dp table」解法
public class Demo07 {
    public static void main(String[] args) {
        System.out.println(fib(20));


    }

    static int fib(int n) {
        if (n < 1) return 0;
        if (n == 2 || n == 1)
            return 1;
        int prev = 1, curr = 1;
        for (int i = 3; i <= n; i++) {
            int sum = prev + curr;
            prev = curr;
            curr = sum;
        }
        return curr;
    }







}
